﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace IndonesiaNews
{
    public class Article
    {
        public String Title { get; set; }
        public String Summary { get; set; }
        public Uri Uri { get; set; }
        public Uri ImageUri { get; set; }
        /// <summary>
        /// Silverlight-specific Image Source.
        /// </summary>
        public String ThumbnailSource { get; set; }
        public String Publisher { get; set; }
        public DateTimeOffset PublishDate { get; set; }
        public String InfoText
        {
            get
            {
                return ToHumanTime(PublishDate.LocalDateTime) + " \u00b7 " + Publisher; 
            }
        }

        public override String ToString()
        {
            return Title;
        }

        private String ToHumanTime(DateTime time)
        {
            var now = DateTime.Now;
            var x = now - time;
            if (x < TimeSpan.FromSeconds(60))
                return "baru";
            else if (x < TimeSpan.FromMinutes(60))
                return x.Minutes.ToString() + " menit";
            else if (x < TimeSpan.FromHours(24))
                return x.Hours.ToString() + " jam";
            else
                return time.ToShortTimeString();
        }

    }
}
